﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;

/// <summary>
/// Summary description for Staff
/// </summary>
public class Staff
{

    public int userId { set; get; }
    public string firstName { set; get; }
    public string lastName { set; get; }
    public string nric { set; get; }
    public string contactNo { set; get; }
    public string email { set; get; }

	public Staff()
	{
		//
		// TODO: Add constructor logic here
		//
	}


    public static Staff getStaffInfo(int userId)
    {
        Staff staff = new Staff();

        var conn = DBManager.getSqlConnection();
        conn.Open();

        string sql = "select userID, firstName, lastName, nric, contactNo, email from Staff where userID = " + userId;
        var cmd = new System.Data.SqlClient.SqlCommand(sql, conn);

        SqlDataReader reader = cmd.ExecuteReader();

        while (reader.Read())
        {
            staff.userId = reader.GetInt32(0);
            staff.firstName = reader.GetString(1);
            staff.lastName = reader.GetString(2);
            staff.nric = reader.GetString(3);
            staff.contactNo = reader.GetString(4);
            staff.email = reader.GetString(5);
        }

        reader.Close();

        conn.Close();


        return staff;
    }
}